package servlet;

import domain.User;
import service.Service;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "addLike", value = "/addLike")
public class addLike extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String src = req.getParameter("src");
        Service service = new Service();
        service.addLike(src);


        User user = (User) req.getSession().getAttribute("user");
        service.addLikeUser(src,user.getUsername());
    }
}
